/* 
题目：输入某年某月某日，判断这一天是这一年的第几天？

程序分析：以3月5日为例，应该先把前两个月的加起来，
然后再加上5天即本年的第几天，特殊情况，闰年且输入月份大于3时需考虑多加一天。
*/

//#include <stdio.h>
//
//int main(void)
//{
//    int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
//    int y, m, d, sum;
//    int i;
//
//    printf("Please enter date:\n");
//    scanf("%d%d%d", &y, &m, &d);
//    if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
//        days[1] = 29;
//    else
//        days[1] = 28;
//    
//    for (size_t i = 0; i < m - 1; i++)
//    {
//        sum += days[i];
//    }
//    sum += d;
//    printf("This is year's %d days.\n", sum);
//
//    return 0;
//}

/* struct 方法 */
#include <stdio.h>

struct DATE
{
    int year;
    int moon;
    int day;
} date;

int main(void)
{
    int sum;
    int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    printf("Please enter date:\n");
    scanf("%d%d%d", &date.year, &date.moon, &date.day);
    
    if ((date.year % 4 == 0 && date.year % 100 != 0) || date.year % 400 == 0)
        days[1] = 29;
    else
        days[1] = 28;

    for (size_t i = 0; i < date.moon - 1; i++)
    {
        sum += days[i];
    }
    sum += date.day;
    printf("This is year's %d days.\n", sum);

    return 0;
}

